// index.js
Page({
  data: {
    banners: [
      {
        id: 1,
        imageUrl: "/images/banners/banner1.jpg",
        linkUrl: ""
      },
      {
        id: 2,
        imageUrl: "/images/banners/banner2.jpg",
        linkUrl: ""
      },
      {
        id: 3,
        imageUrl: "/images/banners/banner3.jpg",
        linkUrl: ""
      }
    ],
    hotProducts: [
      {
        id: 1,
        name: "招牌奶茶",
        price: 18,
        imageUrl: "/images/products/product1.jpg",
        sales: 232
      },
      {
        id: 2,
        name: "芝芝芒果",
        price: 22,
        imageUrl: "/images/products/product2.jpg",
        sales: 188
      },
      {
        id: 3,
        name: "多肉葡萄",
        price: 20,
        imageUrl: "/images/products/product3.jpg",
        sales: 120
      },
      {
        id: 4,
        name: "烤奶",
        price: 19,
        imageUrl: "/images/products/product4.jpg",
        sales: 166
      }
    ],
    newProducts: [
      {
        id: 5,
        name: "草莓波波",
        price: 23,
        imageUrl: "/images/products/product5.jpg",
        tag: "新品"
      },
      {
        id: 6,
        name: "燕麦奶茶",
        price: 19,
        imageUrl: "/images/products/product6.jpg",
        tag: "新品"
      }
    ],
    activities: [
      {
        id: 1,
        title: "会员日5折",
        description: "每周二会员专享5折优惠",
        imageUrl: "/images/activities/activity1.jpg"
      },
      {
        id: 2,
        title: "新品尝鲜",
        description: "新品购买即送小食",
        imageUrl: "/images/activities/activity2.jpg"
      }
    ]
  },

  onLoad() {
    // 页面加载时执行的逻辑
  },

  onShow() {
    // 页面显示时执行的逻辑
  },

  // 跳转到商品详情页
  toDetail(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/detail/detail?id=${id}`
    });
  },

  // 跳转到菜单页
  toMenu() {
    wx.switchTab({
      url: '/pages/menu/menu'
    });
  },

  // 跳转到活动详情
  toActivity(e) {
    const id = e.currentTarget.dataset.id;
    // 这里可以跳转到活动页面，暂时用提示替代
    wx.showToast({
      title: '活动即将开始',
      icon: 'none'
    });
  },

  // 跳转到到店自取菜单页
  toInStoreMenu() {
    wx.navigateTo({
      url: '/pages/in-store-menu/in-store-menu'
    });
  },

  // 跳转到外卖配送地址选择页
  toDeliveryAddress() {
    wx.navigateTo({
      url: '/pages/delivery-address/delivery-address'
    });
  }
})
